Source for file TinyGoogleSpell.class.php
Documentation is available at TinyGoogleSpell.class.php
* Tiny Spelling Interface for TinyMCE Spell Checking.
* Copyright © 2006 Moxiecode Systems AB
function TinyGoogleSpell(&$config, $lang, $mode, $spelling, $jargon, $encoding) {
// Returns array with bad words or false if failed.
$wordstr =
implode(' ', $word_array);
for ($i=
0; $i<
count($matches); $i++
)
$words[] =
$this->unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8"));
$string =
preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string =
preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
return strtr($string, $trans_tbl);
// Returns array with suggestions or false if failed.
foreach ($trans as $k =>
$v)
$trans[$k] =
"&#".
ord($k).
";";
return strtr($string, $trans);
$server =
"www.google.com";
$path =
"/tbproxy/spell?lang=" .
$this->lang .
"&hl=en";
$host =
"www.google.com";
$url =
"https://" .
$server;
$xml =
'<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' .
$word_list .
'</text></spellrequest>';
$header =
"POST ".
$path.
" HTTP/1.0 \r\n";
$header .=
"MIME-Version: 1.0 \r\n";
$header .=
"Content-type: application/PTI26 \r\n";
$header .=
"Content-length: ".
strlen($xml).
" \r\n";
$header .=
"Content-transfer-encoding: text \r\n";
$header .=
"Request-number: 1 \r\n";
$header .=
"Document-type: Request \r\n";
$header .=
"Interface-Version: Test 1.4 \r\n";
$header .=
"Connection: close \r\n\r\n";
//$this->_debugData($xml);
$fp =
fsockopen("ssl://" .
$server, $port, $errno, $errstr, 30);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//$this->_debugData($xml);
// Grab and parse content
preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER);
$fh =
@fopen("debug.log", 'a+');
// Setup classname, should be the same as the name of the spellchecker class
$spellCheckerConfig['class'] =
"TinyGoogleSpell";
Documentation generated on Mon, 05 May 2008 16:23:17 +0400 by phpDocumentor 1.4.0